/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package samoloty.controler;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import samoloty.data.*;
import samoloty.model.IDataModel;
import samoloty.view.MainPanel;
import samoloty.view.MainWindow;
import samoloty.view.MyButton;

/**
 *
 * @author borysfan
 */
public class MainPanelControler implements MyControler {
    
    private MainPanel panel;
    private Controler controler;
    private DBSingleton dataBase= DBSingleton.getInstance();

    public MainPanelControler(Controler c){
        controler = c;
        initPanel();
    }
    
    public MainPanel getPanel(){
        return panel;
    }

    private void initPanel() {
        panel = new MainPanel();
 
        panel.setAircraftBtn1Action(new ATR_42());
        panel.setAircraftBtn2Action(new ATR_72());
        panel.setAircraftBtn3Action(new ERJ_170_100());
        panel.setAircraftBtn4Action(new ERJ_170_200());
        panel.setAircraftBtn8Action(new ERJ_190_200());
        panel.setAircraftBtn5Action(new B737_500());
        panel.setAircraftBtn6Action(new B737_400());
        panel.setAircraftBtn7Action(new B767());
        
    }

    public void setUpWindow(){
        MainWindow window = controler.getView();
        window.setAllBtnStyle(MyButton.ACTIVE_BUTTON);
        window.setLeftPanelVisible(false);
        window.setDisplayVisible(false);
        window.setPrintVisible(false);
        window.setSaveVisible(false); 
    }

    public void firstFocused() {
        
    }

    /*action listenery*/
    private class ATR_42 implements ActionListener{
        public void actionPerformed(ActionEvent e) {
    
            ArrayList<IDataModel> dataModels = new ArrayList<IDataModel>();
            dataModels.add(dataBase.getDataBase1());
            dataModels.add(dataBase.getDataBase13());
            controler.setAcRegPanel(dataModels);
            
        }
    }

    private class ATR_72 implements ActionListener{
        public void actionPerformed(ActionEvent e) {
            ArrayList<IDataModel> dataModels = new ArrayList<IDataModel>();
            dataModels.add(dataBase.getDataBase2());
            controler.setAcRegPanel(dataModels);
        }
    }

    private class ERJ_170_100 implements ActionListener{
        public void actionPerformed(ActionEvent e) {             
                 ArrayList<IDataModel> dataModels = new ArrayList<IDataModel>();
            dataModels.add(dataBase.getDataBase3());
            controler.setAcRegPanel(dataModels);
        }
    }

    private class ERJ_170_200 implements ActionListener{
        public void actionPerformed(ActionEvent e) {
           ArrayList<IDataModel> dataModels = new ArrayList<IDataModel>();
            dataModels.add(dataBase.getDataBase4());
            controler.setAcRegPanel(dataModels);
        }
    }

    private class ERJ_190_200 implements ActionListener{
        public void actionPerformed(ActionEvent e) {
           ArrayList<IDataModel> dataModels = new ArrayList<IDataModel>();
            dataModels.add(dataBase.getDataBase5());
            controler.setAcRegPanel(dataModels);
        }
    }

    private class B737_500 implements ActionListener{
        public void actionPerformed(ActionEvent e) {
           ArrayList<IDataModel> dataModels = new ArrayList<IDataModel>();
            dataModels.add(dataBase.getDataBase6());
            controler.setAcRegPanel(dataModels);
        }
    }

    private class B737_400 implements ActionListener{
        public void actionPerformed(ActionEvent e) {
            ArrayList<IDataModel> dataModels = new ArrayList<IDataModel>();
            dataModels.add(dataBase.getDataBase7());
            dataModels.add(dataBase.getDataBase8());
            dataModels.add(dataBase.getDataBase9());
            controler.setAcRegPanel(dataModels);
        }
    }

    private class B767 implements ActionListener{
        public void actionPerformed(ActionEvent e) {
            ArrayList<IDataModel> dataModels = new ArrayList<IDataModel>();
            dataModels.add(dataBase.getDataBase10());
            dataModels.add(dataBase.getDataBase12());
            dataModels.add(dataBase.getDataBase11());
            controler.setAcRegPanel(dataModels);
        }
    }






}
